package cn.topevery.garden.dal.dao.impl;

import cn.topevery.garden.dal.dao.InteractPlatformDao;
import cn.topevery.garden.entity.po.InteractPlatform;
import cn.topevery.garden.entity.query.InteractPlatformQuery;
import cn.topevery.garden.entity.vo.InteractPlatformVO;
import cn.topevery.garden.framework.base.BaseDaoImpl;
import hw.topevery.framework.db.entity.DataPager;
import hw.topevery.framework.db.entity.SqlQueryMate;
import hw.topevery.framework.db.enums.ScriptConditionEnum;
import hw.topevery.framework.entity.DbCsp;
import hw.topevery.framework.entity.KeyValue;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 互动平台
 *
 * @author code-generate
 * @date 2022-02-18
 */
@Repository
public class InteractPlatformDaoImpl extends BaseDaoImpl<InteractPlatform> implements InteractPlatformDao {
    @Override
    public <P extends DbCsp> List<InteractPlatform> getSearch(P para) {
        return null;
    }

    

    @Override
    public DataPager<InteractPlatformVO> listPage(InteractPlatformQuery query) {
        String table = "t_interact_platform tip";

        String columns = "tip.*";

        int pageIndex = query.pageIndex - 1;
        int pageSize = query.pageSize;

        SqlQueryMate sqlQueryMate = new SqlQueryMate(table).setColumns(columns).setOrderBy("tip.c_status,tip.c_tree_id,tip.c_db_create_date desc");
        sqlQueryMate
                .where(true, "tip.c_db_status", ScriptConditionEnum.Eq, 0)
                .where(!query.getIsApp(), "tip.c_status", ScriptConditionEnum.In, new Integer[]{0,1})
                .where(query.getStatus()!=null, "tip.c_status", ScriptConditionEnum.Eq, query.getStatus())

        ;

        return getDataPager(sqlQueryMate, pageSize, pageIndex, InteractPlatformVO.class);
    }

    @Override
    public InteractPlatform getEntityByColumn(String key,String value){
        KeyValue<String> map=new KeyValue<>();
        map.key=key;
        map.value=value;
        return getEntityByColumnEqValue(map);
    }
}
